package streamtest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;

public class Test02 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"zhangsan,18","lisi,19","wangwu,20");
        //保留年龄大于18的，并收集为map集合，姓名为键，年龄为值
        list.stream().filter(s -> Integer.parseInt(s.split(",")[1]) >= 19)
                .collect(Collectors.toMap(s -> s.split(",")[0], s -> Integer.parseInt(s.split(",")[1])))
                .forEach((k,v) -> System.out.println(k + "==" + v));

    }
}
